
# 定义 员工管理类
import requests
import json


class IhrmEmpApi():
    # 定义添加员工方法
    @classmethod
    def add_emp(cls,header,rep_json):
        resp = requests.post(url="https://ihrm-java.itheima.net/api/sys/user",headers = header,json=rep_json)
        return resp
    # 定义查询员工方法
    @classmethod
    def query_emp(cls,emp_id,header):
        resp2 = requests.get(url="https://ihrm-java.itheima.net/api/sys/user/"+emp_id,
                             headers=header)
        return resp2
    # 定义修改员工方法
    @classmethod
    def modify_emp(cls,emp_id,header,rep_data1):
        resp3 = requests.put(url="https://ihrm-java.itheima.net/api/sys/user/"+emp_id,
                             headers=header, json=rep_data1)
        return resp3
    # 定义删除员工方法
    @classmethod
    def del_emp(cls,emp_id,header):
        resp4 = requests.delete("https://ihrm-java.itheima.net/api/sys/user/"+emp_id,
                                headers=header)
        return resp4
if __name__ == '__main__':
    # rep_header = {"Authorization":"e37ec0ba-0132-4869-af57-84a1263b3df6"}
    # json_data = {
    #         "username":"陈凡琪0521",
    #         "mobile":"15478945217",
    #         "workNumber":"20250758"
    #     }
    # response = IhrmEmpApi.add_emp(rep_header,json_data)
    # print(response.json())
    response1 =IhrmEmpApi.query_emp("1925120602121220096",rep_header)
    print(response1.json())
    json_data1 ={"username":"陈凡琪233"}
    response2 = IhrmEmpApi.modify_emp("1925120602121220096",rep_header,json_data1)
    print(response2.json())
    response3 =IhrmEmpApi.del_emp("1925120602121220096",rep_header)
    print(response3.json())